package singleton.test;

import java.util.concurrent.CountDownLatch;
/*
 * @Author: guqy
 * @Description: CountDownLatch测试
 * @Date 16:50 2018/3/8
 * @param null
 * @return
 */
public class CountDownLatchDemo {
    public static void main(String[] args) {
        int count=5;
        CountDownLatch countDownLatch = new CountDownLatch(count);
        for (int i = 0; i < count; i++) {
            new Thread(() ->{
                try {
                    countDownLatch.await();
                    System.out.println("新线程阻塞后执行~~~~~~~~");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }).start();
            countDownLatch.countDown();
        }
        System.out.println("主线程~~~~~");
    }
}
